package com.example.demo.controller;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class UserController {

    // 1.获得日志对象
    private static Logger logger = LoggerFactory.getLogger(UserController.class);


    @RequestMapping("/helloworld")
    @ResponseBody
    public String helloWorld(String name){
        System.out.println("===========================name:" + name);
        // 2.使用日志对象的日志打印方法，来打印日志
        logger.trace("日志级别：trace");
        logger.debug("日志级别：debug");
        logger.info("日志级别：info");
        logger.warn("日志级别：warn");
        logger.error("日志级别：error");
        return "hi"+name;
    }
}
